/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/remove-duplicates-from-sorted-list
   @Language: C++
   @Datetime: 19-07-08 11:55
   */

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
	ListNode* deleteDuplicates(ListNode* head) {
		if(head==NULL) return NULL;
		ListNode H(-1), *p;
		for(H.next=head, p=head->next; p; p=p->next)
			if(head->val!=p->val) head=p;
			else head->next=p->next;
		return H.next;
	}
};
